<template>
	<view class="settle-box">
		<label class="radio">
			<radio color="#008000"  :checked="isFullCheck" @click="switchState"/><text>全选</text>
		</label>
		<view class="amount-box">
		    合计:<text class="amount">￥{{totalPrice}}</text>
		</view>
		<view class="btn-settle" @click="settleClickHandler">结算({{checkedCount}})</view>
	</view>
</template>

<script>
	import {mapGetters,mapMutations,mapState} from 'vuex'
	export default {
		name:"my-settle",
		data() {
			return {
				
			}
		},
		computed:{
			...mapState('user',['token']),
			...mapGetters('user',['addr']),
			...mapGetters('cart',['checkedCount','total','totalPrice']),
			isFullCheck(){
				return this.total==this.checkedCount
			}
		},
		methods:{
			...mapMutations('cart',['switchAllCartState']),
			switchState(){
				this.switchAllCartState(!this.isFullCheck)
			},
			settleClickHandler(){
				if(this.checkedCount==0){
					return uni.$showMsg('请选择要结算的商品')
				}
				if(!this.addr){
					return uni.$showMsg('请选择收货地址')
				}
				if(!this.token){
					return uni.$showMsg('请先登陆')
				}
			}
		}
	}
</script>

<style lang="scss">
	.settle-box{
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 50px;
		background-color: #efefef;
		display: flex;
		justify-content: space-between;
		align-items: center;
		border: #efefef solid 2px;
		.amount{
			color: #008000;
		}
		.btn-settle{
			background-color: #008000;
			height: 100%;
			color: white;
			line-height: 50px;
			width: 30%;
			text-align: center;
			font-size: 15px;
		}
	}
</style>